<xsl:stylesheet version = '1.0'      xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="fsm"> 
	<html>
		<body>
		<FONT FACE="courier new" SIZE="3">
		<xsl:choose> 
			<xsl:when test="@mtype='moore'"> 
				<strong> 
					<xsl:text>Moore machine  </xsl:text> 
				</strong> 
			</xsl:when> 
			<xsl:when test="@mtype='mealy'"> 
				<strong> 
					<xsl:text>Mealy machine  </xsl:text> 
				</strong> 
			</xsl:when> 
			<xsl:otherwise> 
				<strong> 
					<xsl:text>Finite state machine </xsl:text> 
				</strong>
			</xsl:otherwise> 
		</xsl:choose> 


	  
		<strong>
			<xsl:text> with  </xsl:text> 
			<xsl:value-of select="@numberofstates"/> 
			<xsl:text> states  </xsl:text> 
		</strong>
		<em> 
			<xsl:value-of select="@description"/> 
		</em>
		<br/>
		<xsl:apply-templates select="alphabet"/> 
		<xsl:apply-templates select="states"/> 
		<xsl:apply-templates select="transitions"/> 
		</FONT>
		</body>
	</html>
</xsl:template>

<xsl:template match="alphabet"> 
	<xsl:text> Alphabet </xsl:text> 
	<xsl:value-of select="@atype"/> 
	<xsl:text>:  </xsl:text> 
	
	<xsl:for-each select="char"> 
                    <xsl:value-of select="@cvalue"/> 
		<xsl:text>  </xsl:text> 
          </xsl:for-each> 
	<br/>
</xsl:template>

<xsl:template match="states"> 
	<br/>
	<table border="1">
		<caption>States </caption>
		<tr bgcolor="#999999">
			<th>ID</th>
			<th>Output value</th>
		</tr>
	<xsl:for-each select="state"> 
		<tr>
			<td align="right">
			          <xsl:if test="@initial='true'"> 
					<xsl:text>i </xsl:text> 
				</xsl:if> 

				<xsl:if test="@final='true'"> 
					<xsl:text> f</xsl:text> 
				</xsl:if> 

				<xsl:value-of select="@id"/>
			</td> 
			
			<td align="center">
			<xsl:if test="@value=''"> 
					<xsl:text> --</xsl:text> 
			</xsl:if> 
			<xsl:value-of select="@svalue"/> 
			</td> 
		</tr>	
	  </xsl:for-each> 
	</table>
	
</xsl:template>

<xsl:template match="transitions"> 
	<br/>
	<table border="1">
		<caption>Transitions </caption>
		<tr bgcolor="#999999">
			<th>From state</th>
			<th>To state</th>
			<th>Reading</th>
			<th>Writing</th>
		</tr>
	<xsl:for-each select="transition"> 
		<tr>
			<td align="center">
			         <xsl:value-of select="@from"/>
			</td> 
			<td align="center">
			         <xsl:value-of select="@to"/>
			</td> 
			<td align="center">
			         <xsl:value-of select="@reading"/>
			</td> 
			<td align="center">
				<xsl:if test="@writing=''"> 
					<xsl:text> --</xsl:text> 
				</xsl:if> 
			         <xsl:value-of select="@writing"/>
			</td> 
		</tr>	
	  </xsl:for-each> 
	</table>
	
</xsl:template>


</xsl:stylesheet> 